/***
 *nptrace.h - TRACE basic functions
 *    Copyright (c) 2005-2010, Beijing NetPosa Technologies Co.,Ltd. All rights reserved.
 *Purpose:
 **************************************************************************************/

#ifndef _nptrace_h_
#define _nptrace_h_

#if _MSC_VER > 1000
	#pragma once
#endif

#include "npdebug.h"
#include "npmsel.h"

#define TRACE_TIME_FILE_LINE()											\
		do																\
		{																\
			SYSTEMTIME t;												\
			GetLocalTime(&t);											\
			dbg_printf(_T("%s(%d): %04d-%02d-%02d %02d:%02d:%02d %03dms | "),	\
					__FILE__, __LINE__									\
					, t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond, t.wMilliseconds \
					);													\
		} while(false)

#define TraceExBase						TRACE_TIME_FILE_LINE(); GLOBAL_SCOPE dbg_printf

#ifdef _DEBUG
	#define TRACE_EX					TraceExBase
	#define TRACE_EX0(sz)				do { TRACE_TIME_FILE_LINE(); GLOBAL_SCOPE dbg_printf(_T("%s"), sz); } while(false)
	#define TRACE_EX1(fmt, p1)			do { TRACE_TIME_FILE_LINE(); GLOBAL_SCOPE dbg_printf(fmt, p1); } while(false)
	#define TRACE_EX2(fmt, p1, p2)		do { TRACE_TIME_FILE_LINE(); GLOBAL_SCOPE dbg_printf(fmt, p1, p2); } while(false)
	#define TRACE_EX3(fmt, p1, p2, p3)	do { TRACE_TIME_FILE_LINE(); GLOBAL_SCOPE dbg_printf(fmt, p1, p2, p3); } while(false)
#else
	#define TRACE_EX					1 ? (void)0 : GLOBAL_SCOPE dbg_printf
	#define TRACE_EX0(sz)
	#define TRACE_EX1(fmt, p1)
	#define TRACE_EX2(fmt, p1, p2)
	#define TRACE_EX3(fmt, p1, p2, p3)
#endif

#endif	/* #ifndef _nptrace_h_ */
